import Loading from '../../components/Loading/Loading.vue'
import Rotation from '../../components/Rotation/Rotation.vue'
import HongBao from '../../components/RedPacket/RedPacket.vue'
import couponVue from '../../components/pupUp/youhuiquan.vue'
export default {
	components: {
		Loading,
		Rotation,
		HongBao,
		couponVue


	},
	props: [
		'courseID'
	],
	data() {
		return {
			msg: "测试成功",
			isLoading: false,
			loadStatus: 'load',
			lunBoData: [], //轮播数据
			isCard: false,
			footH: this.CustomBar,
			TabCur: 0,
			scrollLeft: 0,
			courseList: [], //课程列表
		}
	},
	onReady() {
		//自动跳转到指定的课程
		// if (this.courseID != "") {
		// 	this.toGoods(this.courseID);
		// }
		//获取数据
		this.Reques.commonQuest('xcx/course.api.php', "GET", {
			"action": "getIndexPage"
		}).then((res) => {
			console.log(res);
			if (res.statusCode == 200 && res.data.code == 0) {
				this.lunBoData = res.data.data.lunbo;
				this.isLoading = true;
				this.courseList = res.data.data.courseList;

			} else {
				this.loadStatus = 'error2';
			}

		}, (err) => {
			console.log(err);
			this.loadStatus = 'error2';
		});
		this.sendOutCoupon(1);
	},

	methods: {
		/**
		 * 发放优惠券
		 * @param {Object} dat
		 */
		sendOutCoupon(dat) {
			this.Reques.checkLogin((d) => {
				if (!d) {
					uni.getStorage({
						key: "startTime",
						success: (res) => {
							console.log("starttIEM" + res)
						},
						fail: () => {
						    this.$refs.RedPack.openRed();
							uni.setStorage({
								key: "startTime",
								success: () => {
									
									console.log("存储成功")
								},
								fail: () => {
									console.log("存储失败");
								}
							})
						}
					});
				

				}

			});


		},



		/**
		 * 进入课程详情
		 * @param {Object} id
		 */
		toGoods(id) { //跳转商品详情
			uni.navigateTo({
				animationDuration: 500,
				url: "/pages/goodDetail/home?courseId=" + id,
				animationType: 'slide-in-bottom',

			});
		}



	}





}
